Skip to content

feat: Rust port of kopdeltav — eliminate Python dependency for desktop app - #12

Merged
yuuka-dev merged 10 commits into
mainfrom
dev
Apr 3, 2026
Merged

feat: Rust port of kopdeltav — eliminate Python dependency for desktop app#12
yuuka-dev merged 10 commits into
mainfrom
dev

Conversation

@yuuka-dev

Copy link
Copy Markdown
Owner

Summary

  • kopdeltav/ Python パッケージを Rust に 1:1 移植し、src-tauri/crates/kopdeltav/ として独立 workspace crate 化
  • Tauri Commands (invoke()) で直接フロントエンドから Rust を呼び出す構成に変更。Python サブプロセス・HTTP レイヤーを完全排除
  • フロントエンドの useApi.tsfetch()invoke() に移行
  • Python CLI (run.py + kopdeltav/) は維持(デュアルメンテナンス)

Architecture

Before:  Frontend --fetch()--> FastAPI (Python) --import--> kopdeltav (Python)
After:   Frontend --invoke()--> Tauri Commands (Rust) --call--> kopdeltav (Rust)

Rust modules (1:1 port)

Module Lines Description
models.rs 404 CurveKey, Atmosphere, OrbitalElements, CelestialBody, hermite_interp
parser.rs 856 Kopernicus ConfigNode parser
calculator.rs 1107 ΔV calculation engine
system.rs 654 CelestialSystem tree building, SOI, sort_by_transfer_dv
i18n.rs 493 Translation tables (ja/en/id)
commands.rs 693 13 Tauri command handlers

Test plan

  • 77 Rust tests pass (cargo test -p kopdeltav)
  • Clippy clean (cargo clippy -p kopdeltav -- -D warnings)
  • 288 Python tests still pass (pytest tests/ -v)
  • Frontend type-check pass (pnpm type-check)
  • Frontend build pass (pnpm build)
  • Manual: Tauri app launch on Windows (cargo tauri dev)
  • Manual: Upload .cfg and verify body list
  • Manual: Launch/Hohmann/Tsiolkovsky calculations match Python output

yuuka-dev added 10 commits April 3, 2026 09:24
…ermite interpolation

Port Python kopdeltav/models.py to Rust as a separate workspace crate
(crates/kopdeltav) to isolate core physics from Tauri dependencies.

Includes: CurveKey, Atmosphere, OrbitalElements, CelestialBody structs,
G0/R_GAS constants, compute_mu(), and KSP AnimationCurve-compatible
hermite_interp(). All 11 tests pass, clippy clean.
Port the Python kopdeltav/parser.py to Rust with 1:1 logic parity.
Two-layer design: low-level ConfigNode tree parser and high-level
CelestialBody extractor. Handles comments, MM modifiers, delete
directives, curve keys with tangent defaults, inline brace formats,
unclosed brace recovery, and #LOC_ display name fallback.
Port all calculator functions from Python kopdeltav/calculator.py to Rust:
- Orbital mechanics: low_orbit_altitude, circular/escape velocity
- Atmospheric density via hermite-interpolated curves (kPa->Pa conversion)
- Launch delta-V with empirical gravity/drag/jet estimation
- Hohmann transfer (inward + outward) via vis-viva equation
- Tsiolkovsky rocket equation for mass ratio
- Geostationary orbit altitude and transfer delta-V
- Escape/landing delta-V helpers
- Multi-step route planner (compute_route)

All 17 tests pass including reference value regression tests:
- Sanctar escape velocity: 3802 m/s
- Kerbin escape velocity: 3431 m/s
- Sanctar surface density: 1.4096 kg/m3
- Sanctar launch rocket: ~3110 m/s, with jets: ~1982 m/s
Add system.rs with build_tree, is_barycenter, sort_by_transfer_dv,
and scan_configs. Add i18n.rs with full ja/en/id translation tables
and get_text/get_all_keys API with language fallback.
Replace the Python subprocess spawning architecture with native Rust
Tauri commands that directly call the kopdeltav crate. Add state.rs
for shared AppState (bodies + system tree) and commands.rs with 13
IPC handlers covering health, config upload, GameData scan, body
listing/detail, launch/hohmann/tsiolkovsky calculations, system
tree, destinations, route planning, atmosphere profiles, and moon
queries. Remove tauri-plugin-shell dependency and Python resource
bundling from tauri.conf.json.
Migrate all HTTP fetch-based API calls in useApi.ts to Tauri invoke()
from @tauri-apps/api/core, update ConfigUpload.vue to read file as text
before passing to invoke, and remove the vite dev server proxy config.
@yuuka-dev
yuuka-dev merged commit 7944a32 into main Apr 3, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant